home *** CD-ROM | disk | FTP | other *** search
- /*
- File: FrazBinaries.h
-
- Version: 1.5
- Date: August 2000
-
- Copyright © 1999-2000 Dan Wright, All rights reserved.
-
- Bugs?: Please include the name of this file, the version, and the date (above).
- Send bug reports to danwr@kagi.com.
-
- Updates: http://www.halcyon.com/danwr/smoothie.html
- */
-
- #ifndef __FRAZBINARIES__
- #define __FRAZBINARIES__
-
-
- #if PRAGMA_ONCE
- #pragma once
- #endif
-
- #include "FrazAPI.h"
- #include "FrazRegistry.h"
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT
- #pragma import on
- #endif
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
- #elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
- #elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
- #endif
-
-
- enum {
- /* binary formats */
- kBinFormatPEF = FOUR_CHAR_CODE('peff'), /* standard CFM format. Defined in PEFBinaryFormat.h. */
-
- kBinFormatXCOFF = FOUR_CHAR_CODE('xcof'), /* Defined in XCOFF.h. Reserved for future use. */
-
- kBinFormatMachO = FOUR_CHAR_CODE('Mach'), /* NeXT/OpenStep/Mach/Rhapsody/OS X. Reserved for future use. */
-
- kBinFormatCOFF = FOUR_CHAR_CODE('coff'), /* Reserved for the heck of it. */
-
- kBinFormatVectorLib = FOUR_CHAR_CODE('VLib'), /* OS X. Reserved for future use. */
- kBinFormatBridgeLib = FOUR_CHAR_CODE('BLib'), /* OS X. Reserved for future use. */
-
- kBinFormatPEF2 = FOUR_CHAR_CODE('PEF '), /* Reserved for future use. */
- kBinFormatRanLib = FOUR_CHAR_CODE('ranl') /* OS X. Reserved for future use. */
- };
-
- enum { /* error codes */
- errUnsupportedBinFormat = 9000, /* no plug-in for format */
- errIncompatibleBFX = 9001, /* binary format plug-in exists but is incompatible w/us or OS version */
- errNotFragment = 9002, /* not a fragment (or incorrect BinFormat specified) */
- errCorruptFragment = 9003,
- errBadReference = 9004, /* bad BrowserRef, FragmentRef, LibraryRef, WindowRef... */
- errEndOfList = 9005, /* index beyond end of list */
- errUnsupportedOp = 9006, /* operation not supported for this format */
- errDuplicateLocator = 9007, /* locator already registered */
- errNoFragmentsFound = 9008 /* BFXScan found no fragments */
- };
-
- typedef struct FrazDiskFlatLocator
- {
- ConstFSSpecPtr fileSpec;
- UInt32 offset;
- UInt32 length;
- } FrazDiskFlatLocator;
-
- typedef struct FrazMemoryLocator
- {
- LogicalAddress address;
- UInt32 length;
- Boolean inPlace;
- UInt8 reservedA;
- UInt16 reservedB;
- } FrazMemoryLocator;
-
- typedef struct FrazResourceLocator
- {
- ConstFSSpecPtr fileSpec;
- OSType rsrcType;
- SInt16 rsrcID;
- UInt16 offset; /* note: this differs from CFragSystem7SegmentedLocator, where this is a reserved field */
- } FrazResourceLocator;
-
- typedef struct FrazGenericLocator
- {
- UInt32 field1;
- UInt32 field2;
- UInt32 field3;
- } FrazGenericLocator;
-
- typedef struct FrazLocator
- {
- SInt32 where;
- union {
- FrazDiskFlatLocator onDisk;
- FrazMemoryLocator inMem;
- FrazResourceLocator inSegs;
- FrazGenericLocator generic;
- } u;
- } FrazLocator;
-
- typedef const FrazLocator *ConstFrazLocatorPtr;
-
- #define FrazLocatorIsFileLocator(where) \
- (CFragHasFileLocation(where) || (where < 0))
-
-
- typedef FourCharCode BinFormat;
-
-
- typedef struct OpaqueBinFragmentAccess *FrazAccessRef;
- typedef FrazAccessRef FrazLocatorRef; /* old name */
-
- typedef void* GenericReference;
-
- enum {
- // fragment properties
- kFrazPropLibraryCount = FOUR_CHAR_CODE('lcnt'), /* UInt32 */
- kFrazPropSectionCount = FOUR_CHAR_CODE('xcnt'), /* UInt16 */
-
- kFrazPropLibMapPrivately = FOUR_CHAR_CODE('priv'), /* Boolean */
- kFrazPropAppSubdirID = FOUR_CHAR_CODE('dird'), /* SInt32 (directory ID) */
- kFrazPropAppLibDirID = FOUR_CHAR_CODE('dird'), /* directory ID */
- kFrazPropAppStackSize = pAppStackSize, /* UInt32 */
-
- // section properties
- kFrazPropSharing = pSharingKind,
- kFrazPropOffset = FOUR_CHAR_CODE('offs'), /* UInt32 */
- kFrazPropAlignment = FOUR_CHAR_CODE('alig'), /* UInt8 (power of 2) */
- kFrazPropDefaultAddress = FOUR_CHAR_CODE('defa'), /* UInt32 */
- kFrazPropSizeOnDisk = FOUR_CHAR_CODE('cbod'),
- kFrazPropSizeLoaded = FOUR_CHAR_CODE('cbim'),
- kFrazPropSectionKind = FOUR_CHAR_CODE('kind'),
-
- kFrazPropSectionSegment = FOUR_CHAR_CODE('zSeg'), /* typeChar (name) */
-
- kFrazPropContainsCode = FOUR_CHAR_CODE('$cod'), /* Boolean */
-
- // main/init/term: properties of section
- kFrazPropMain = FOUR_CHAR_CODE('main'), /* UInt32 (offset) */
- kFrazPropInitialization = FOUR_CHAR_CODE('init'),
- kFrazPropTermination = FOUR_CHAR_CODE('term'),
-
- // library properties
- kFrazPropWeakLink = pWeakLink, /* boolean */
- kFrazPropInitBefore = FOUR_CHAR_CODE('ipre'), /* boolean */
- kFrazPropSymbolCount = FOUR_CHAR_CODE('scnt'), /* UInt32 (can be derived) */
- kFrazPropCurrentVersion = FOUR_CHAR_CODE('vers'), /* UInt32 */
- kFrazPropOldestCompatible = FOUR_CHAR_CODE('verz'), /* UInt32 */
-
- // symbol properties
- kFrazPropSymbolClass = FOUR_CHAR_CODE('csym'), /* CFragSymbolClass */
- kFrazPropSection = FOUR_CHAR_CODE('sect') /* SInt16 */
- // also kFrazPropOffset, kFrazPropWeakLink
-
- };
-
- enum {
- /* values for kFrazPropSectionKind */
- kFrazCodeSection = 0, /* Code, presumed pure & position independent.*/
- kFrazUnpackedDataSection = 1, /* Unpacked writeable data.*/
- kFrazPackedDataSection = 2, /* Packed writeable data.*/
- kFrazDataSection = kFrazUnpackedDataSection,
- kFrazConstantSection = 3, /* Read-only data.*/
- kFrazLoaderSection = 4, /* Loader tables.*/
- kFrazDebugSection = 5, /* Reserved for future use.*/
- kFrazExecDataSection = 6, /* Intermixed code and writeable data.*/
- kFrazExceptionSection = 7, /* Reserved for future use.*/
- kFrazTracebackSection = 8 /* Reserved for future use.*/
- };
-
- enum {
- /* values for kFrazPropSharing */
- kFrazPrivateShare = 0, /* Shared only within a "private" closure. */
- kFrazProcessShare = 1, /* Shared within a single process.*/
- kFrazGlobalShare = 4, /* Shared across the entire system.*/
- kFrazProtectedShare = 5 /* Readable across the entire system, writeable only to privileged code.*/
- };
-
- // --------------------------------------------------------------------------------------
-
- pascal OSErr FrazOpen(ConstFrazLocatorPtr, SInt16 fsPerm, FrazLocatorRef *pRef);
- pascal void FrazClose(FrazLocatorRef);
- pascal OSErr FrazRead(FrazLocatorRef, UInt32 offset, Size *pcb, void *buf);
- pascal OSErr FrazWrite(FrazLocatorRef, UInt32 offset, Size cb, void *buf);
- pascal OSErr FrazGetFragmentSize(BinFormat, FrazLocatorRef, Size *pcb);
-
- pascal Boolean FrazReferenceIsValid(OSType theClass, GenericReference);
-
- enum {
- kFrazScanExports = 1,
- kFrazScanImportSymbols = 2,
- kFrazScanLibraries = 6,
- kFrazScanFragmentInfo = 8,
- kFrazScanAll = kFrazScanFragmentInfo | kFrazScanLibraries | kFrazScanExports,
-
- kFrazScanRelocate = 16 // Locator has become invalid
- };
-
- pascal OSErr FrazRescanFragment(FragmentRef fragment, long scanFlags);
-
- pascal ConstFrazLocatorPtr FrazGetFragmentLocator(FragmentRef);
-
- pascal FragmentRef FrazFindFragmentByLocator(BrowserRef *inoutBrowser, ConstFrazLocatorPtr);
- pascal FragmentRef FrazFindFragmentByLocatorAndName(BrowserRef *inoutBrowser, ConstFrazLocatorPtr, ConstStringPtr);
-
-
-
- #if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
- #elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
- #elif PRAGMA_STRUCT_PACK
- #pragma pack()
- #endif
-
- #ifdef PRAGMA_IMPORT_OFF
- #pragma import off
- #elif PRAGMA_IMPORT
- #pragma import reset
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __FRAZBINARIES__ */